package org.ysu.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ysu.entity.Admin;
import org.ysu.service.AdminRoleService;
import org.ysu.service.AdminService;
import org.ysu.vo.ResultVO;
import org.ysu.vo.RoleAdminVO;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 管理员角色关联表 前端控制器
 * </p>
 *
 * @author liushuo
 * @since 2024-08-16
 */
@RestController
@RequestMapping("/adminRole")
public class AdminRoleController {
    @Resource
    AdminService adminService;
    @Resource
    AdminRoleService adminRoleService;
    @GetMapping("/getAdmin")
    ResultVO<RoleAdminVO> getAdminList (Long roleId) {
        return ResultVO.success(new RoleAdminVO(adminService.getList(), adminRoleService.getByRoleId(roleId)));
    }

    @PostMapping("/save")
    ResultVO<Boolean> save(Long roleId, Long[] adminIds) {
        return ResultVO.success(adminRoleService.save(roleId, adminIds));
    }
}
